Build the custom ops AOT libs as C++20 - #21689
Conversation
ATen requires C++20, so every target that compiles a real PyTorch header needs to opt in. Most already do, but the two custom ops AOT libs were missed: custom_ops_aot_lib compiles torch/library.h through op_sdpa_aot.cpp, and the lib built by gen_custom_ops_aot_lib compiles the generated RegisterSchema.cpp, which includes the same header. Both still build at C++17 against the pinned PyTorch, so this is only visible when building against a newer PyTorch, where they fail on std::strong_ordering in c10/util/intrusive_ptr.h.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21689
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 3 Unrelated FailuresAs of commit 44ac399 with merge base 48741ac ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Summary
A few ExecuTorch build targets compile real PyTorch headers, instead of the small copy of
c10that ships inside this repo. ATen (the PyTorch tensor library) now needs C++20, so every one of those targets has to ask for C++20 explicitly.Most already do:
util,portable_lib,_training_lib, and the LLM runner all setCXX_STANDARD 20. Two were missed:custom_ops_aot_libinextension/llm/custom_ops/CMakeLists.txt. It compilesop_sdpa_aot.cpp, which includes<torch/library.h>.gen_custom_ops_aot_libintools/cmake/Codegen.cmake. It compiles the generatedRegisterSchema.cpp, which includes the same header.Both still build at C++17 against the currently pinned PyTorch, so nothing is broken today. The problem shows up when building against a newer PyTorch, where the compile fails inside
c10/util/intrusive_ptr.h, which usesstd::strong_ordering, a C++20 feature:The fix is two lines, in the same form the other targets already use:
set_target_properties(custom_ops_aot_lib PROPERTIES CXX_STANDARD 20)Test plan
Configured on Linux x86_64 with
EXECUTORCH_BUILD_KERNELS_LLM_AOT=ONandEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON, then compared the compile flags incompile_commands.jsonbefore and after the change:Exactly the two intended targets change, and no other target is affected.
Also compiled every source file shared by these targets under C++20 to confirm none of them relies on C++17-only behavior (7 files, all pass).